function results=compute_results(config,estimates)

    %%%%%%%%%%%%%%%%
    % LOAD IN
    %%%%%%%%%%%%%%%%

theta=estimates.theta;
theta_star=estimates.theta_star;
reps=config.reps;
CI=config.CI;

p_interest=config.p_interest;
y_interest=config.y_interest;
p_interest_univ=config.p_interest_univ;
y_interest_univ=config.y_interest_univ;

N=config.N;   

    %%%%%%%%%%%%%%%%
    % INITIALIZE
    %%%%%%%%%%%%%%%%

alpha=5;
    
    %%%%%%%%%%%%%%%%
    % COMPUTE SHAT
    %%%%%%%%%%%%%%%%

[shat,qhat,g_level,~,g2_level,~,~,~,sl_level,d_shat_dlog_p,d_shat_dlog_y]=predict_demand(theta,config);

    % CI 
    
if CI==1,
    
    qhat_star=NaN*ones(size(qhat,1),reps);
    g_level_star=NaN*ones(size(qhat,1),reps);
    g2_level_star=NaN*ones(size(qhat,1),reps);

    for rr=1:reps, 
       [~,qhat_star(:,rr),g_level_star(:,rr),~,g2_level_star(:,rr),~,~,~,~,~,~]=predict_demand(theta_star(:,rr),config);
    end;
        
    [CI_logQ_low, CI_logQ_high]=compute_CIs_byincome(qhat,qhat_star,reps,p_interest,y_interest,p_interest_univ,y_interest_univ);

end;

    % DWL

DWL=NaN*ones(3,1);
DWL_pertax=DWL;
DWL_perinc=DWL;
DWL_tri=DWL;
DWL_tri_pertax=DWL;
DWL_tri_perinc=DWL;

CI_DWL_low=NaN*ones(3,1);
CI_DWL_high=CI_DWL_low;
CI_DWL_perinc_low=NaN*ones(3,1);
CI_DWL_perinc_high=CI_DWL_low;
CI_DWL_pertax_low=NaN*ones(3,1);
CI_DWL_pertax_high=CI_DWL_low;

for yy=1:3,

    [DWL(yy,1), DWL_pertax(yy,1), DWL_perinc(yy,1),DWL_tri(yy,1), DWL_tri_pertax(yy,1), DWL_tri_perinc(yy,1)]=find_DWL(config,g_level,g2_level,yy);

    if CI==1,
    
        DWL_star=NaN*ones(reps,1);
        DWL_pertax_star=DWL_star;
        DWL_perinc_star=DWL_star;
                    
        for rr=1:reps,
            [DWL_star(rr,1), DWL_pertax_star(rr,1), DWL_perinc_star(rr,1),~,~,~]=find_DWL(config,g_level_star(:,rr),g2_level_star(:,rr),yy);
        end;

        [CI_DWL_low(yy,1), CI_DWL_high(yy,1)] = get_ci (DWL(yy,1), DWL_star(:,1),     alpha, 1, N, N, 'symmetrical');            
        [CI_DWL_perinc_low(yy,1), CI_DWL_perinc_high(yy,1)] = get_ci (DWL_perinc(yy,1), DWL_perinc_star(:,1),     alpha, 1, N, N, 'symmetrical');            
        [CI_DWL_pertax_low(yy,1), CI_DWL_pertax_high(yy,1)] = get_ci (DWL_pertax(yy,1), DWL_pertax_star(:,1),     alpha, 1, N, N, 'symmetrical');            
                    
    end;
    
end;
          
    %%%%%%%%%%%%%%%%
    % OUTPUT
    %%%%%%%%%%%%%%%%

results.qhat=qhat;
results.sl_level=sl_level;
results.sl_alt=d_shat_dlog_p + d_shat_dlog_y.*shat - shat.*(1-shat);

if CI==1,

    results.CI_logQ_low=CI_logQ_low;
    results.CI_logQ_high=CI_logQ_high;

end;

results.DWL=DWL;
results.DWL_pertax=DWL_pertax;
results.DWL_perinc=DWL_perinc;
results.DWL_tri=DWL_tri;
results.DWL_tri_pertax=DWL_tri_pertax;
results.DWL_tri_perinc=DWL_tri_perinc;

if CI==1,

    results.CI_DWL_low=CI_DWL_low;
    results.CI_DWL_high=CI_DWL_high;
    results.CI_DWL_perinc_low=CI_DWL_perinc_low;
    results.CI_DWL_perinc_high=CI_DWL_perinc_high;
    results.CI_DWL_pertax_low=CI_DWL_pertax_low;
    results.CI_DWL_pertax_high=CI_DWL_pertax_high;

end;



    %
